package com.ljq;

import static com.ljq.Ui.printMonster;
import static com.ljq.Ui.printWin;

public class Scene {
    RoomSet roomSet=new RoomSet();//定义存放所有房间的对象
    Person person=new Person();
    monster1 monster = new monster1();
    Monster monster2 = new Monster();
    MonsterSet monsterSet= new MonsterSet();
    PersonSet personSet =new PersonSet();


    public void initScene () {
        initRooms();
        initPerson(roomSet.searchRoomById("1"));
        initMonster1(roomSet.searchRoomById("6"));
        initMonster(roomSet.searchRoomById("4"));
    }

    public void play(){
       if(person.getCurrentRoom().getId().equals("6")){
           System.out.println("怪物"+monster.getName()+"展开攻势,当前生命值为"+monster.getHp()+"攻击力是"+monster.getCE());
           monster.useArticle(new Teeth("weapon2",10,"牙齿撕咬"),person);
           System.out.println("person剩余血量为"+person.hp);
       }
        if(person.getCurrentRoom().getId().equals("4")){
            System.out.println("怪物"+"展开攻势,当前生命值为"+monster2.getHp()+"攻击力是"+monster2.getCE());
            monster2.useArticle(new Teeth("weapon2",10,"牙齿撕咬"),person);
            System.out.println("person剩余血量为"+person.hp);
        }

    }
    public void defence(){
        int  i=0;
        if (person.getCurrentRoom().getId().equals("6")){
            System.out.println("person展开攻势,当前生命值为"+person.getHp()+"攻击力是"+person.getCE());
            person.useArticle(new Sword("weapon1",20,"剑击"),monster);
            System.out.println("怪物剩余血量为"+monster.hp);
            if (monster.hp <=0){
                printMonster();
                i++;
            }
        }
        if (person.getCurrentRoom().getId().equals("4")){
            System.out.println("person展开攻势,当前生命值为"+person.getHp()+"攻击力是"+person.getCE());
            person.useArticle(new Sword("weapon1",20,"剑击"),monster2);
            System.out.println("怪物剩余血量为"+monster2.getHp());
            if (monster2.getHp()<=0){
                printMonster();
                i++;
            }
        }
        if (i==2){
            printWin();
        }

    }


    private void initMonster(Room room) {
        monster.setCurrentRoom(room);
    }

    private void initMonster1(Room room) {
        monster.setCurrentRoom(room);
    }

    public  void initRooms(){
        Room outside,learning_room, lobby, pub,swim_pool, bedroom, washroom;
        outside = new Room("1","花园");
        lobby = new Room("2","大堂");
        pub = new Room("3","酒吧");
        learning_room = new Room("4","书房");
        bedroom = new Room("5","卧室");
        swim_pool = new Room("6","游泳池");
        washroom = new Room("7","卫生间");

        outside.addReachableRoom("2",lobby);
        outside.addReachableRoom("3",pub);
        outside.addReachableRoom("5",bedroom);
        outside.addReachableRoom("6",swim_pool);
        lobby.addReachableRoom("1", outside);
        lobby.addReachableRoom("4", learning_room);
        lobby.addReachableRoom("7",washroom);
        pub.addReachableRoom("1", outside);
        learning_room.addReachableRoom("2",lobby);
        learning_room.addReachableRoom("5",bedroom);
        bedroom.addReachableRoom("4", learning_room);
        bedroom.addReachableRoom("1", outside);
        swim_pool.addReachableRoom("1",outside);
        washroom.addReachableRoom("2",lobby);

        roomSet.addRoom(outside);
        roomSet.addRoom(lobby);
        roomSet.addRoom(pub);
        roomSet.addRoom(learning_room);
        roomSet.addRoom(bedroom);
        roomSet.addRoom(washroom);
        roomSet.addRoom(swim_pool);
//
//        monster1 mon = new monster1();
//        mon.setCurrentRoom(swim_pool);
//        mon.show();
    }
    private void initPerson(Room room) {
        person.setCurrentRoom(room);
        person.setHp(120);
        person.setCE(40);
        person.setCurrentArticle(new Sword("weapon1",20,"sword"));
    }

    private void initMonster(){
        monster2.setId("monster2");
        monster2.setDescription("牛魔王");
        monster2.setHp(50);
        monster2.setCurrentArticle(new Teeth("weapon2",10,"牙齿撕咬"));
        monsterSet.getMonsters().add(monster2);
    }
    private  void  initMonster1(){

        monster.setId("monster");
        monster.setDescription("食人鱼");
        monster.setHp(40);
        monster.setCurrentArticle(new Teeth("weapon2",10,"牙齿撕咬"));
        monsterSet.getMonsters().add(monster);
    }

    public RoomSet getRoomSet() {
        return roomSet;
    }

    public void setRoomSet(RoomSet roomSet) {
        this.roomSet = roomSet;
    }

    public Person getPerson() {
        return person;
    }

    public void setPerson(Person person) {
        this.person = person;
    }

    public Monster getMonster() {
        return monster;
    }
//
//    public void setMonster(monster1 monster) {
//        this.monster = monster;
//    }

    public Monster getMonster2() {
        return monster2;
    }

    public void setMonster2(Monster monster2) {
        this.monster2 = monster2;
    }

    public MonsterSet getMonsterSet() {
        return monsterSet;
    }

    public void setMonsterSet(MonsterSet monsterSet) {
        this.monsterSet = monsterSet;
    }

//    public Monster getMonster() {
//        return monster;
//    }

    public void setMonster(monster1 monster) {
        this.monster = monster;
    }
}
